package com.bwie.auth.handler;

import com.alibaba.nacos.shaded.com.google.protobuf.ServiceException;
import com.bwie.common.result.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局统一异常
 */
@RestControllerAdvice
@Log4j2
public class GlobalHandler {

    @ExceptionHandler(ServiceException.class)
    public Result serviceHandler(ServiceException serviceException){
        log.info("异常信息：{}",serviceException.getMessage());
        return Result.error(serviceException.getMessage());
    }
}
